package GUI.view;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import client.domainModels.NodeImpl.LogFile;

public class TableJPanel extends JPanel {

	LogFile log;
	JPanel southPanel;
	public TableJPanel(final LogFile log){
		this.log = log;
		southPanel = new JPanel();
		this.setLayout(new BorderLayout());
		init();
	}
	
	public TableJPanel(final LogFile log,final String buttonName,final ActionListener al){
		this.log = log;
		southPanel = new JPanel();
		this.setLayout(new BorderLayout());
		final JButton button = new JButton(buttonName);
		button.addActionListener(al);
		southPanel.removeAll();
		southPanel.add(button);
		this.add(southPanel, BorderLayout.SOUTH);
		init();
	}
	private void init(){
		final JTable table = MultiLineTableConstructor.createLogTable(log);
		final JScrollPane scrollPanel = new JScrollPane(table);
		this.add(scrollPanel, BorderLayout.CENTER);
	}
	
	public LogFile getLogFile(){
		return log;
	}
	
	
	
	
}
